#!/usr/bin/env python
"""
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/473852
A simple script for making random passwords, WITHOUT 1,l,O,0.  Because
those characters are hard to tell the difference between in some fonts.
"""

#Import Modules
import sys
from random import Random

def getpasswd():
    rng = Random()
    out = ""

    righthand = 'vbQ.~!@#$%^&*WERTASDrt23456qweasdfgzxcFGZXCVB'
    lefthand = 'phjknmYU.~!@#$%^&*PHJK789yuioLNM'
    allchars = righthand + lefthand

    try:
        passwordLength = int(sys.argv[1])
    except:
        #user didn't specify a length.  that's ok, just use 15
        passwordLength = 15
    try:
        alternate_hands = sys.argv[2] == 'alt'
        if not alternate_hands:
            print "USAGE:"
            print sys.argv[0], "[length of password]",
            print "[alt (if you want the password to alternate hands]"
    except:
        alternate_hands = False

    for i in range(passwordLength):
        if not alternate_hands:
            #sys.stdout.write( rng.choice(allchars) )
            out += rng.choice(allchars)
        else:
            if i%2:
                #sys.stdout.write( rng.choice(lefthand) )
                out += rng.choice(allchars)
            else:
                #sys.stdout.write( rng.choice(righthand) )
                out += rng.choice(allchars)
    #sys.stdout.write('\n')
    return out

if __name__ == "__main__":
    for i in range(10):
        print getpasswd()
